package org.hertsig.magiccardmarket.entities;

import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import lombok.AllArgsConstructor;
import lombok.Delegate;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Getter @ToString
@AllArgsConstructor @NoArgsConstructor
@XmlRootElement(name="response")
public class Products implements Iterable<Products.Product> {
	@Delegate(types=Iterable.class) @XmlElement private List<Product> product;
	
	@Getter @ToString
	@AllArgsConstructor @NoArgsConstructor
	public static class Product {
		@XmlElement private String idProduct;
		@XmlElement private String idMetaproduct;
		@XmlElement private List<ProductName> name;
		
		// While the documentation specifies there can be multiple Category and PriceGuide elements in the response,
		// I have never seen it actually return more than one
		@XmlElement private Category category;
		@XmlElement private PriceGuide priceGuide;
		
		@XmlElement private String image;
		@XmlElement private String expansion;
		@XmlElement private String rarity;
		
		@Getter @ToString
		@AllArgsConstructor @NoArgsConstructor
		public static class ProductName {
			@XmlElement private Integer idLanguage;
			@XmlElement private String languageName;
			@XmlElement private String productName;
		}
		
		@Getter @ToString
		@AllArgsConstructor @NoArgsConstructor
		public static class Category {
			@XmlElement private String idCategory;
			@XmlElement private String categoryName;
		}
		
		@Getter @ToString
		@AllArgsConstructor @NoArgsConstructor
		public static class PriceGuide {
			@XmlElement(name="SELL") private Double sell;
			@XmlElement(name="LOW") private Double low;
			@XmlElement(name="AVG") private Double avg;
		}
	}
}
